<template>
	<view class="index">
			<view class="input-group">
				<!-- <uinput label="姓名" v-model="hotel.id"  placeholder="请输入姓名"></uinput> -->
				<uinput label="酒店" v-model="hotel.hotelName"  placeholder="酒店名"></uinput>
				<uinput label="房号" v-model="hotel.roomNum" placeholder="房间号"></uinput>
				<uinput label="姓名" v-model="hotel.name" placeholder="入住人姓名"></uinput>
			</view>
			<button @click="getRoom">验证</button>
			
		</view>
</template>

<script>
import uinput from '@/components/poiuy-uinput/uinput.vue';
import {_getRoomEquipment} from '../../common/vmeitime-http/controller.js'
import Vue from 'vue'
export default {
  components: { uinput },
  data() {
    return {
		room:{},
		hotel:{}
					
    };
  },
  onLoad(param) {
  	console.log(param)
	// this.getRoom(param)
	this.room = param
	// this.$set(this.hotel,hotelName)
	this.hotel.hotelName = this.room.hotelName;
	this.hotel.roomNum = this.room.roomNum
	this.hotel.hotelId = this.room.hotelId
  },
  methods:{
	  
	  getRoom(){
		  _getRoomEquipment({hotelId:this.hotel.hotelId,realName:this.hotel.name,roomNumber:this.room.roomNum}).then(res =>{
			  console.log(res)
			  this.screen(res.data.data.equipmentExecutors)
			  res.data.data.realName = this.hotel.name
			  uni.setStorageSync("controller",res.data.data)
			  uni.redirectTo({
			  	url: this.room.url
			  })
		  })
	  },
	  screen(equipment){
		  var LIGHT = [];
		  var AIR_CONDITION = [];
		  var CURTAIN = [];
		  var SCENE_TRIGGER = [];
		  var DOORLOCK = [];
		  for (var i = 0; i < equipment.length; i++) {
		  	switch(equipment[i].duerosType){
				case "LIGHT":
						LIGHT.push({
							avator:"/static/icon/dengOn.png",
							static:"/static/icon/dengOff.png",
							text:equipment[i].modelName,
							active:1,
							controlType: equipment[i].controlType,
							duerosType: equipment[i].duerosType,
							equipId: equipment[i].equipId,
							modelName: equipment[i].modelName,
							position: equipment[i].position,
							positionBak: equipment[i].positionBak,
						})
						break;
				case "AIR_CONDITION":
						AIR_CONDITION.push({
							avator:"/static/icon/dengOn.png",
							static:"/static/icon/dengOff.png",
							text:equipment[i].modelName,
							active:1,
							controlType: equipment[i].controlType,
							duerosType: equipment[i].duerosType,
							equipId: equipment[i].equipId,
							modelName: equipment[i].modelName,
							position: equipment[i].position,
							positionBak: equipment[i].positionBak,
						})
						break;
				case "CURTAIN":
						CURTAIN.push({
							avator:"/static/icon/dengOn.png",
							static:"/static/icon/dengOff.png",
							text:equipment[i].modelName,
							active:1,
							controlType: equipment[i].controlType,
							duerosType: equipment[i].duerosType,
							equipId: equipment[i].equipId,
							modelName: equipment[i].modelName,
							position: equipment[i].position,
							positionBak: equipment[i].positionBak,
						})
						break;
				case "SCENE_TRIGGER":
						SCENE_TRIGGER.push({
							avator:"/static/icon/dengOn.png",
							static:"/static/icon/dengOff.png",
							text:equipment[i].modelName,
							active:1,
							controlType: equipment[i].controlType,
							duerosType: equipment[i].duerosType,
							equipId: equipment[i].equipId,
							modelName: equipment[i].modelName,
							position: equipment[i].position,
							positionBak: equipment[i].positionBak,
						})
						break;
					case "DOORLOCK":
							DOORLOCK.push({
								avator:"/static/icon/dengOn.png",
								static:"/static/icon/dengOff.png",
								text:equipment[i].modelName,
								active:1,
								controlType: equipment[i].controlType,
								duerosType: equipment[i].duerosType,
								equipId: equipment[i].equipId,
								modelName: equipment[i].modelName,
								position: equipment[i].position,
								positionBak: equipment[i].positionBak,
							})
							break;
			}
		  }
		  
		  var equipmentlist = {
			  LIGHT,
			  SCENE_TRIGGER,
			  CURTAIN,
			  AIR_CONDITION,
			  DOORLOCK
		  }
		  uni.setStorageSync('equipmentlist',equipmentlist)
	  }
 //    btnclick(item) {
	// 		 if(this.list.list[item].active==1){
	// 			 this.list.list[item].active=0
	// 		//	Vue.set(item,'active', '0')
				
	// 		}else{
	// 			this.list.list[item].active=1
	// 	//	Vue.set(item,'active','1')
	// 		// 	item.active = 1
	// 		}
	// 		//console.log(item)
	
 //    }
  }
};
</script>


<style>

</style>